﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PineLake.Drmwe.Caching.MemoryCache
{
    /// <summary>
    /// 缓存接口
    /// </summary>
    public interface ICaching
    {
        #region 设置缓存

        /// <summary>
        /// 缓存项是否存在
        /// </summary>
        /// <param name="Key">缓存的Key</param>
        /// <returns></returns>
        public bool Exists(string Key);
        /// <summary>
        /// 添加缓存
        /// </summary>
        /// <param name="Key">缓存Key</param>
        /// <param name="Value">缓存Value</param>
        /// <param name="ExpiresSliding">滑动过期时长（如果在过期时间内有操作，则以当前时间点延长过期时间</param>
        /// <param name="ExpiressAbsoulte">绝对过期时长</param>
        /// <returns></returns>
        public bool Set(string Key, object Value, TimeSpan ExpiresSliding, TimeSpan ExpiressAbsoulte);
        /// <summary>
        /// 添加缓存
        /// </summary>
        /// <param name="Key">缓存Key</param> 
        /// <param name="Value">缓存Value</param>
        /// <param name="ExpiresIn">缓存时长</param>
        /// <param name="IsSliding">是否滑动过期（如果在过期时间内有操作，则以当前时间点延长过期时间）</param>
        /// <returns></returns>
        public bool Set(string Key, object Value, TimeSpan ExpiresIn, bool IsSliding = false);
        /// <summary>
        /// 添加缓存
        /// </summary>
        /// <param name="Key">缓存Key</param>
        /// <param name="Value">缓存Value</param>
        /// <returns></returns>
        public void Set(string Key, object Value);
        /// <summary>
        /// 添加缓存
        /// </summary>
        /// <param name="Key">缓存Key</param>
        /// <param name="Value">缓存Value</param>
        /// <param name="Ts">缓存时长</param>
        public void Set(string Key, object Value, TimeSpan Ts);
        /// <summary>
        /// 添加缓存
        /// </summary>
        /// <param name="key">缓存Key</param>
        /// <param name="value">缓存Value</param>
        /// <param name="seconds">秒</param>
        public void Set(string key, object value, int seconds);
        #endregion

        #region 删除缓存
        /// <summary>
        /// 删除缓存
        /// </summary>
        /// <param name="Key">缓存Key</param>
        /// <returns></returns>
        public void Remove(string Key);
        /// <summary>
        /// 批量删除缓存
        /// </summary>
        /// <param name="Keys">缓存Keys列表</param>
        public void RemoveAllByKeys(IEnumerable<string> Keys);
        /// <summary>
        /// 删除所有缓存
        /// </summary>
        public void RemoveCacheAll();


        #endregion

        #region 获取缓存
        /// <summary>
        /// 获取缓存
        /// </summary>
        /// <param name="Key">缓存Key</param>
        /// <returns></returns>
        public object Get(string Key);
        /// <summary>
        /// 获取缓存
        /// </summary>
        /// <typeparam name="T">范类型实例</typeparam>
        /// <param name="key">缓存Key</param>
        /// <returns></returns>
        public T Get<T>(string Key);
        /// <summary>
        /// 获取所有缓存键
        /// </summary>
        /// <returns></returns>
        public List<string> GetCacheKeys();
        #endregion
    }
}
